package com.jdls.tanhua.web;

import com.jdls.tanhua.dto.RecommendUserDto;
import com.jdls.tanhua.server.TanHuaServer;
import com.jdls.tanhua.vo.FateValueVo;
import com.jdls.tanhua.vo.NearUserVo;
import com.jdls.tanhua.vo.PageResult;
import com.jdls.tanhua.vo.TodayBest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author 嘉德罗斯
 * @date 2021/10/26
 */
@RestController
@RequestMapping("/tanhua")
public class TanHuaWeb {

    @Autowired
    private TanHuaServer tanHuaServer;

    @GetMapping("/todayBest")
    public ResponseEntity todayBest(){

        FateValueVo fateValueVo = tanHuaServer.find();
        return ResponseEntity.ok(fateValueVo);
    }


    @GetMapping("/recommendation")
    //推荐好友
    public ResponseEntity recommendation(RecommendUserDto recommendUserDto){
        PageResult result = tanHuaServer.recommendation(recommendUserDto);
        return ResponseEntity.ok(result);
    }

    @GetMapping("/{id}/personalInfo")
    //查询佳人信息
    public ResponseEntity personalInfo(@PathVariable Long id){
        FateValueVo vo = tanHuaServer.personalInfo(id);
        return ResponseEntity.ok(vo);
    }

    @GetMapping("/strangerQuestions")
    //查询陌生人问题
    public ResponseEntity strangerQuestions(Long userId){
        String message = tanHuaServer.strangerQuestions(userId);
        return ResponseEntity.ok(message);
    }

    @PostMapping("/strangerQuestions")
    //回复陌生人问题
    public ResponseEntity strangerQuestions(@RequestBody Map map){
        tanHuaServer.strangerQuestions(map);
        return ResponseEntity.ok(null);
    }

    @GetMapping("/cards")
    //探花左滑右滑
    public ResponseEntity cards(){
        List<TodayBest> todayBests= tanHuaServer.cards();
        return ResponseEntity.ok(todayBests);
    }

    @GetMapping("/{id}/{type}")
    //左滑右滑
    public ResponseEntity love(@PathVariable Long id,@PathVariable String type){
        tanHuaServer.love(id,type);
        return ResponseEntity.ok(null);

    }

    @GetMapping("/search")
    //搜附近
    public ResponseEntity search(String gender, @RequestParam(defaultValue = "2000") String distance){

        List<NearUserVo> nearUserVos = tanHuaServer.search(gender,distance);
        return ResponseEntity.ok(nearUserVos);

    }
}
